/**
 * 验证邮箱
 * @type {Array}
 */
export const emailInput = [
  { required: true, type:'email', message: '请输入正确的邮箱地址', trigger: 'blur' },
];

/**
 * 验证手机号
 * @type {Array}
 */
export const phoneNumInput = [
  { required: true, message: '请输入手机号', trigger: 'blur' },
  { pattern: /^1\d{10}$/ || /^[0-9]*$/, message: '手机号格式不正确', trigger: 'blur' }
];

/**
 * 验证手机号不必填
 * @type {Array}
 */
export const phoneNumInputN = [
  { message: '请输入手机号', trigger: 'blur' },
  { pattern: /^1\d{10}$/ || /^[0-9]*$/, message: '手机号格式不正确', trigger: 'blur' }
];

/**
* 短信验证码验证
* @type {Array}
*/
export const verifyCodeInput = [
  { required: true, message: '请输入验证码', trigger: 'blur' },
  { len: 6, message: '验证码格式不正确', trigger: 'blur' },
];

/**
* 密码验证
* @type {Array}
*/
export const passwordInput = [

  { required: true, message: '请输入密码', trigger: 'blur' },
  { min: 6, message: '密码长度不小于6位', trigger: 'blur' }
]

/**
* 修改密码
* @type {Array}
*/
export const resetPasswordInput = [
  { required: true, message: '请输入密码', trigger: 'blur' },
  { pattern:/^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).([A-Z]|[a-z]|[0-9]|[,./!@#$%^&]){5,19}$/, message: '密码格式有误', trigger: 'blur' }
]

/**
* 年龄验证
* @type {Array}
*/
export const ageInput = [
  { required: true, message: '请输入', trigger: 'blur' },
  { pattern: /^(?:[1-9][0-9]?|1[01][0-9]|120)$/,min: 1, message: '只能输入正整数', trigger: 'blur' }
]

export const ageInputN = [
  { pattern: /^(?:[1-9][0-9]?|1[01][0-9]|120)$/,min: 1, message: '只能输入正整数', trigger: 'blur' }
]

/**
* 员工编号验证
* @type {Array}
*/
export const employeeNoInput = [
  { required: true, message: '请输入', trigger: 'blur' },
  { pattern: /^([1-9]\d{0,2}|1000)$/,min: 1, message: '只能输入1-1000的正整数', trigger: 'blur' }
]

/**
* 身份证验证
* @type {Array}
*/
export const idNumInput = [
  { required: true, message: '请输入', trigger: 'blur' },
  { pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,min: 1, message: '身份证号码不正确', trigger: 'blur' }
]

export const idNumInputN = [
  { pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,min: 1, message: '身份证号码不正确', trigger: 'blur' }
]

/**
* 咨询原文链接
* @type {Array}
*/
export const infomationLinkInput = [
  { required: true, message: '请输入原文链接', trigger: 'blur' },
  { min: 1, max: 300, message: "300个字符以内", trigger: "blur" },
  { type: "url", message: '链接格式不正确', trigger: 'blur' }
]

/**
* [校验是否必传]
* @param  {[type]} message [description]
* @return {[type]}         [description]
*/
export const requireInput = (message, ev = "blur") => [
  { required: true, message: message, trigger: ev },
  { pattern: /^[^'"<>%\\]+$/, message: '不能含有特殊字符', trigger: 'blur' }
]

/**
*  * [校验是否必传]
* @param  {[type]} message [description]
* @return {[type]}         [description]
*/
export const requireInputWithMaxLength = (message, min=0, max=15, ev = "blur") => [
  { required: true, message: message, trigger: ev },
  { min: min, max: max, message: `只能输入${min}到${max}个字符`, trigger: ev },
  { pattern: /^[^'"<>%\\]+$/, message: '不能含有特殊字符', trigger: 'blur' }
]

/**
*  * [校验字符长度，非必传]
* @param  {[type]} message [description]
* @return {[type]}         [description]
*/
export const requireInputWithMaxLengthN = (min=0, max=15, ev = "blur") => [
  { min: min, max: max, message: `只能输入${min}到${max}个字符`, trigger: ev },
  { pattern: /^[^'"<>%\\]+$/, message: '不能含有特殊字符', trigger: 'blur' },
]


/**
日期验证
 */
// export const validateDate = (rule, value, callback) => {
//   let num = new Date(this.searchObj.startTime).getTime() - new Date(this.searchObj.endTime).getTime();
//   if (num > 0) {
//       callback(new Error('开始时间不能超过结束时间'));
//   } else if (value == "") {
//       callback(new Error('请选择结束时间'));
//   } else {
//       callback();
//   }
// };
